package com.alibaba.seckill.controller;


import com.alibaba.seckill.utils.ExcelUtils;
import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.schema.MultiPartName;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.util.IOUtils;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 曹帅
 * @since 2021-11-18
 */
@Controller
@RequestMapping("/seckillOrder")
@Slf4j
public class SeckillOrderController {
    @PostMapping("/test")
    public void test(@RequestParam MultipartFile file) throws IOException {
        try {
            //list为excel数据集合
            List<ArrayList<String>> list = ExcelUtils.readExcel(file);
            for (int i = 0; i < list.size(); i++) {
                //第一行数据集合
                List list1 = list.get(i);
                for (int j = 0; j < list1.size(); j++) {
                    //第一行每个单元格数据
                    System.out.println(list1.get(j));
                }

            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}